package com.harisucici.websocketlib.room;


import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.harisucici.websocketlib.entities.send.P2PSendHoleEntity;

import java.util.List;

@Dao
public abstract class P2PUnSendDao {
    @Insert
    public abstract void insertMsg(P2PSendHoleEntity entity);

    @Update
    public abstract void updateMsg(P2PSendHoleEntity entity);

    @Delete
    public abstract void deleteMsg(P2PSendHoleEntity entity);

    @Query("delete from P2PSendHoleEntity")
    public abstract void deleteAll();


    @Query("delete from P2PSendHoleEntity where appSeqId=:appSeqId")
    public abstract void deleteMsgById(long appSeqId);

    @Query("select * from P2PSendHoleEntity")
    public abstract List<P2PSendHoleEntity> listMsg();

    @Query("select * from P2PSendHoleEntity where appSeqId=:appSeqId")
    public abstract P2PSendHoleEntity findMsgById(long appSeqId);

    @Query("select * FROM P2PSendHoleEntity ORDER BY appSeqId DESC LIMIT 0,1")
    public abstract P2PSendHoleEntity findTop();
}
